Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

327
Views
En JsDoc, ¿debería `[key: string]: any;` permitirme usar cualquier propiedad de valor clave?

Estoy usando npm pacakge jsonwebtoken y el método jwt.verify. Cuando trato de deconstruir el valor devuelto, aparece un error de intellisense

 Property 'userId' does not exist on type 'string | JwtPayload'.

Mi código se ve así.

 ({ userId } = jwt.verify(token, 'my_secret'));

Cuando miro el index.d.ts para jsonwebtoken tiene esto

 export function verify(token: string, ...): JwtPayload | string; export interface JwtPayload { [key: string]: any; iss?: string | undefined; ... }

¿No debería la [key: string]: any; me permite crear cualquier propiedad de valor clave?

¿Por qué sigo recibiendo errores tipográficos y hay alguna manera de deshacerme de ellos usando jsdocs?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Si usa corchetes para acceder al valor, no se quejará.

Algo como esto

 const payload = jwt.verify(token, 'my_secret')) payload["userId"];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!